package com.hema.auction.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hema.auction.R;
import com.hema.auction.adapter.BigImgAdapter;
import com.hema.auction.base.BaseActivity;
import com.hema.auction.bean.SunSquareInfo;
import com.hema.auction.utils.Constant;
import com.hema.auction.utils.GlideUtils;
import com.hema.auction.utils.Utils;
import com.hema.auction.widget.view.RefreshRecyclerView;
import com.hema.auction.widget.view.TitleView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 晒单详情
 * author by john
 */

public class SunDetailActivity extends BaseActivity {

    @BindView(R.id.title_view)
    TitleView titleView;
    @BindView(R.id.refresh_recycler_view)
    RefreshRecyclerView refreshRecyclerView;
    private BigImgAdapter adapter;
    private SunSquareInfo info;
    private View headerView;
    private ImageView ivIcon;
    private TextView tvTitle;
    private TextView tvDate;
    private TextView tvContent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sun_detail);
        ButterKnife.bind(this);
        init();
    }

    private void init(){
        info = getIntent().getParcelableExtra(Constant.EXTRA_SUN_INFO);
        if(info != null){
            headerView = LayoutInflater.from(this).inflate(R.layout.layout_sun_detail_header,null);
            adapter = new BigImgAdapter(info.getImgs());
            adapter.addHeaderView(headerView);
            refreshRecyclerView.setVerLayoutManager();
            refreshRecyclerView.setAdapter(adapter);

            ivIcon = (ImageView) headerView.findViewById(R.id.iv_icon);
            tvTitle = (TextView) headerView.findViewById(R.id.tv_title);
            tvDate = (TextView) headerView.findViewById(R.id.tv_date);
            tvContent = (TextView) headerView.findViewById(R.id.tv_content);
            GlideUtils.load(this,info.getFacePic(),ivIcon);
//            Glide.with(this).load(info.getFacePic()).placeholder(R.drawable.ic_defaul_image).into(ivIcon);
            tvTitle.setText(info.getGoodName());
            tvDate.setText(Utils.timedate(info.getAddtime()));
            tvContent.setText(info.getContents());
        }
    }

}
